//
//  STHairerInfoVC.m
//  YiYueHairdresser
//
//  Created by zhouzhouzhou on 2018/10/10.
//  Copyright © 2018年 YuYiLian. All rights reserved.
//

#import "STHairerInfoVC.h"
#import "STHairerInfoView.h"
#import "STDoorInfoVC.h"
#import "STCommentMagVC.h"
#import "STHairProsVC.h"
#import "STOrderFooter1View.h"
#import "NSDate+EUHelper.h"
#import "ChatViewController.h"


@interface STHairerInfoVC ()<STHairerInfoViewDelegate>{
    UIButton * hairLikeBtn ;
    NSDictionary * hairerInfoDic;
    STHairerInfoView * hairerView;
    STHairDetailInfoModel * hairInfoModel ;
}

@end

@implementation STHairerInfoVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self wr_setNavBarBackgroundAlpha:0];
    [self wr_setNavBarBarTintColor:[UIColor whiteColor]];
    [self wr_setNavBarTintColor:[UIColor blackColor]];
    [self wr_setNavBarShadowImageHidden:YES];
    
    hairLikeBtn =[[UIButton alloc]init];
    [hairLikeBtn setImage:[UIImage imageNamed:@"c-selLike"] forState:UIControlStateNormal];
    [hairLikeBtn setImage:[UIImage imageNamed:@"c-cancellike"] forState:UIControlStateSelected];
    [hairLikeBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    hairLikeBtn.frame=CGRectMake(0, 0, 30, 30);
    [hairLikeBtn addTarget:self action:@selector(actionLikeHairer) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem * likeBarBtn = [[UIBarButtonItem alloc]initWithCustomView:hairLikeBtn];
    
    UIButton * shareBtn =[[UIButton alloc]init];
    [shareBtn setImage:[UIImage imageNamed:@"c-share"] forState:UIControlStateNormal];
    [shareBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    shareBtn.frame=CGRectMake(0, 0, 30, 30);
    [shareBtn addTarget:self action:@selector(actionShareHairer) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem * shareBarBtn = [[UIBarButtonItem alloc]initWithCustomView:shareBtn];
    
    self.navigationItem.rightBarButtonItems =@[shareBarBtn,likeBarBtn];
    
    [self loadHairerInfoView];
    [self loadHairerInfoData];
}

- (void)actionShareHairer {
}


- (void)actionLikeHairer {
    hairLikeBtn.selected = !hairLikeBtn.selected ;
    [STMainPageService collectionHairerWithStylistId:self.stylistId type:hairLikeBtn.selected completion:^(id result, NSError *error) {
        if (error) {
            [ZYHCommonMethod showError:error];
        }
    }];
}


- (void)loadHairerInfoData {
    [STMainPageService getHairerInfo:self.stylistId completion:^(id result, NSError *error) {
        if (error) {
            [ZYHCommonMethod showError:error];
        }
        hairInfoModel = [STHairDetailInfoModel modelWithJSON:result];
        if(!hairInfoModel){
            hairInfoModel = [STHairDetailInfoModel new];
        }
        hairInfoModel.mobile = @"15019800462";
        hairInfoModel.serviceTime = @"10:00-22:00";
        hairerView.hairerInfoData =hairInfoModel;
        hairLikeBtn.selected =hairInfoModel.isCollection;
        self.isSign = hairInfoModel.nexus;
        [hairerView setHairerView];
    }];
}

- (void)loadHairerInfoView {
    hairerView = [[STHairerInfoView alloc]initWithFrame:CGRectMake(0, -64, SCREEN_WIDTH, SCREEN_HEIGHT+64)];
    hairerView.hairerInfoData =hairInfoModel;
    hairerView.delegate = self;
    [hairerView setHairerView];
    hairerView.backgroundColor = [UIColor whiteColor];
    
    [self.view addSubview:hairerView];
    
}

//选择的门店
-(void)hairerInfoViewSignHouseSelNum:(int)selNum{
    STDoorInfoVC * doorInfoVC  =[STDoorInfoVC new];
    STHairStoreModel * model = hairInfoModel.cardStoreDTOs[selNum];

    doorInfoVC.isSign = NO;
    doorInfoVC.stylistId = model.stylistId;
    doorInfoVC.hidesBottomBarWhenPushed= YES;
    [self.navigationController pushViewController:doorInfoVC animated:YES];
}
//查看所有评论
-(void)hairerInfoViewTurnToAllCommentVC{
    STCommentMagVC * commentInfoVC  =[STCommentMagVC new];
    commentInfoVC.stylistId = self.stylistId;
    commentInfoVC.hidesBottomBarWhenPushed= YES;
    [self.navigationController pushViewController:commentInfoVC animated:YES];
}

//查看美发师作品
-(void)hairerInfoViewTurnToAllProjectVC{
    STHairProsVC* prosVC  =[STHairProsVC new];
    prosVC.stylistId = hairInfoModel.stylistId;
    prosVC.hidesBottomBarWhenPushed= YES;
    [self.navigationController pushViewController:prosVC animated:YES];
}

@end
